﻿using AspDotNet.Framework.Mvc.FirstDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AspDotNet.Framework.Mvc.FirstDemo.Controllers
{
    public class ViewDataController : BaseController
    {
        // GET: ViewBag
        public ActionResult Index1()
        {
            return View(Student.Students);
        }
        public ActionResult Index2()
        {
            ViewBag.Students=Student.Students;
            return View();
        }
        public ActionResult Index3()
        {
            ViewData.Add("Students", Student.Students);
            return View();
        }
        public ActionResult Index4()
        {
            ViewData.Add("Students1", Student.Students);
            /* ViewBag 在内部将数据插入到 ViewData 字典中 */
            /* ViewData 的生命只在当前 HTTP 请求期间持续。 如果发生重定向，ViewData 值将被清除 */
            ViewBag.Students2 = Student.Students;/* ViewData中的键跟ViewBag属性名称不能相同 */
            return View();
        }
    }
}